// 页面加载完成后执行
document.addEventListener('DOMContentLoaded', function() {
    console.log('页面加载完成');

    // 获取DOM元素
    const title = document.querySelector('h1');
    const links = document.querySelectorAll('a');

    // 修改标题颜色动画
    let colors = ['#2c3e50', '#e74c3c', '#27ae60', '#9b59b6'];
    let currentIndex = 0;

    setInterval(() => {
        title.style.color = colors[currentIndex];
        currentIndex = (currentIndex + 1) % colors.length;
    }, 1000);

    // 为所有链接添加点击事件
    links.forEach(link => {
        link.addEventListener('click', function(e) {
            console.log('点击了链接: ' + this.textContent);

            // 如果是测试链接，阻止默认行为并显示提示
            // if (this.textContent.includes('测试')) {
            //     e.preventDefault();
            //     alert('这是测试链接，实际开发中会跳转到: ' + this.getAttribute('href'));
            // }
        });
    });

    // 图片悬停效果
    const logo = document.querySelector('img');
    if (logo) {
        logo.addEventListener('mouseover', () => {
            logo.style.transform = 'scale(1.1)';
            logo.style.transition = 'transform 0.3s';
        });

        logo.addEventListener('mouseout', () => {
            logo.style.transform = 'scale(1)';
        });
    }

    // 显示当前日期
    const dateElement = document.createElement('div');
    dateElement.style.textAlign = 'center';
    dateElement.style.marginTop = '20px';
    dateElement.style.color = '#7f8c8d';
    dateElement.textContent = '当前日期: ' + new Date().toLocaleDateString();
    document.body.appendChild(dateElement);
});